import 'package:flutter/material.dart';
import 'package:flutter_swiper/flutter_swiper.dart';

class HomeBannerWidget extends StatefulWidget {
  const HomeBannerWidget({Key key}) : super(key: key);

  @override
  _HomeBannerWidgetState createState() => _HomeBannerWidgetState();
}

class _HomeBannerWidgetState extends State<HomeBannerWidget> {
  List<String> banners = [
    "https://cdn.pixabay.com/photo/2020/06/18/18/48/highway-5314645_960_720.jpg",
    "https://cdn.pixabay.com/photo/2015/04/23/22/00/tree-736885_960_720.jpg",
    "https://cdn.pixabay.com/photo/2015/03/26/09/47/sky-690293_960_720.jpg",
    "https://cdn.pixabay.com/photo/2015/09/09/16/05/forest-931706_960_720.jpg"
  ];
  @override
  Widget build(BuildContext context) {
    double width = MediaQuery.of(context).size.width;
    double height = width * 540.0 / 1080.0;
    return Container(
      margin: EdgeInsets.only(left: 5, right: 5),
      width: width,
      height: height,
      child: Swiper(
        autoplay: true,
        itemCount: banners.length,
        itemBuilder: (BuildContext context, int index) {
          return Image.network(banners[index],
              width: width, height: height, fit: BoxFit.cover);
        },
      ),
    );
  }
}
